import json

dic = {
    "name": "qiuqiu",
    'age': 18,
}
# 1.文件的位置
# 2.模式，w(直接写，会覆盖)a(在后面拼接)

with open('./data.txt', 'w', encoding='utf-8') as f:
    # python对象转为json格式字符串
    json_str = json.dumps(user_json)
    f.write(json_str)
    print("成功写入")
    pass